package com.zwk.edu.controller;


import com.zwk.base.entity.CommonResult;
import com.zwk.edu.entity.subject.OneSubject;
import com.zwk.edu.service.SubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author zwk
 * @since 2022-08-21
 */
@RestController
@RequestMapping("/edu/subject")
@CrossOrigin
public class SubjectController {

    @Autowired
    private SubjectService subjectService;

    // 添加课程分类
    @PostMapping("/addSubject")
    public CommonResult addSubject(MultipartFile multipartFile){
        // 上传excel文件
        subjectService.saveByExcel(multipartFile, subjectService);
        return CommonResult.ok();
    }

    // 获取所有课程分类信息
    @GetMapping("/getAllSubject")
    public CommonResult getAllSubject(){

        List<OneSubject> list = subjectService.findAllSubject();

        return CommonResult.ok().data("list", list);
    }

}

